package logic

import (
	"context"
	"houseRpc/models"

	"houseRpc/house"
	"houseRpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DownHouseLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDownHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownHouseLogic {
	return &DownHouseLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DownHouseLogic) DownHouse(in *house.DownHouseRequest) (*house.DownHouseResponse, error) {
	// todo: add your logic here and delete this line

	models.DB.Debug().Model(&models.House{}).
		Where("DATE_ADD(created_at, INTERVAL 30 DAY) < NOW()").
		Where("status = 1").Update("Status", 2)

	return &house.DownHouseResponse{}, nil
}
